<template>
    <div>
        <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.9.12/skins/default/aliplayer-min.css" />
        <script charset="utf-8" type="text/javascript" src="https://g.alicdn.com/de/prismplayer/2.9.12/aliplayer-min.js"></script>
        <div class="prism-player" id="J_prismPlayer"></div>
    </div>
</template>
<script>
import vod from "@/api/vod"

export default {
    layout: 'video',//应用video布局
    asyncData({params, error}) {
        return vod.getPlayAuth(params.id)
            .then(resposne => {
                return {
                    playAuth: resposne.data.data.playAuth,
                    vid: params.id
                }
            })
    },
    mounted() {
        var player = new Aliplayer({
            id: 'J_prismPlayer',
            width: '100%',
            autoplay: true,
            height: '500px',
            // 播放方式二：推荐点播用户使用
            vid: this.vid,
            playauth: this.playAuth,
            //当播放私有加密流时需要'设'置
            encryptType: '1',
            rePlay: true
        }, function(player) {
            console.log('The player is created.')
        });
    }

}
</script>